﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Analyzer = Lucene.Net.Analysis.Analyzer;
using StandardAnalyzer = Lucene.Net.Analysis.Standard.StandardAnalyzer;
using Document = Lucene.Net.Documents.Document;
using FilterIndexReader = Lucene.Net.Index.FilterIndexReader;
using IndexReader = Lucene.Net.Index.IndexReader;
using QueryParser = Lucene.Net.QueryParsers.QueryParser;
using FSDirectory = Lucene.Net.Store.FSDirectory;
using Version = Lucene.Net.Util.Version;
using Collector = Lucene.Net.Search.Collector;
using IndexSearcher = Lucene.Net.Search.IndexSearcher;
using Query = Lucene.Net.Search.Query;
using ScoreDoc = Lucene.Net.Search.ScoreDoc;
using Scorer = Lucene.Net.Search.Scorer;
using Searcher = Lucene.Net.Search.Searcher;
using TopScoreDocCollector = Lucene.Net.Search.TopScoreDocCollector;

namespace FisheryPlatform.Search.Index
{
    public abstract class IndexData
    {        
    }

    internal class AnonymousClassCollector : Collector
    {
        #region
        private Scorer scorer;
        private int docBase;

        // simply print docId and score of every matching document
        public override void Collect(int doc)
        {
            //return ("doc=" + doc + docBase + " score=" + scorer.Score());
        }

        public override bool AcceptsDocsOutOfOrder()
        {
            return true;
        }

        public override void SetNextReader(IndexReader reader, int docBase)
        {
            this.docBase = docBase;
        }

        public override void SetScorer(Scorer scorer)
        {
            this.scorer = scorer;
        }
        #endregion
    }

    /// <summary>Use the norms from one field for all fields.  Norms are read into memory,
    /// using a byte of memory per document per searched field.  This can cause
    /// search of large collections with a large number of fields to run out of
    /// memory.  If all of the fields contain only a single token, then the norms
    /// are all identical, then single norm vector may be shared. 
    /// </summary>
    internal class OneNormsReader : FilterIndexReader
    {
        #region
        private System.String field;

        public OneNormsReader(IndexReader in_Renamed, System.String field)
            : base(in_Renamed)
        {
            this.field = field;
        }

        public override byte[] Norms(System.String field)
        {
            return in_Renamed.Norms(this.field);
        }
        #endregion
    }
}
